package web_k;

import pojo_k.HomeUserIncome;
import pojo_k.HomeUserPayout;
import service_k.BankService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet("/bankAnalyseServlet")
public class BankAnalyseServlet extends HttpServlet {
    private BankService service = new BankService();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String homeuserName = request.getParameter("homeuserName");

        List<HomeUserIncome> homeUserIncomes = service.selectAllIncome(homeuserName);
        List<HomeUserPayout> homeUserPayouts = service.selectAllPayout(homeuserName);

        request.setAttribute("homeuserIncomes",homeUserIncomes);
        request.setAttribute("homeuserPayouts",homeUserPayouts);

        request.getRequestDispatcher("BankAnalyse2.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
